
<%@page import="com.spmanage.util.HttpUtil"%>
<%@page import="com.spmanage.util.BillingUtil"%><%@page import="com.spmanage.util.DbOperation"%>
<%@page import="com.spmanage.util.SqlUtil"%><%@page import="com.spmanage.util.WebAction"%>
<%@page import="com.spmanage.util.StringUtil"%><%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%><%
	WebAction webAction = new WebAction(request,response);
    
    System.out.println("IVR拨打参数："+request.getQueryString());
    
    String mobile = webAction.getParameterString("mobile");
    String myChannel = webAction.getParameterString("channel");
    String callno = webAction.getParameterString("callno");
    String calltime = webAction.getParameterString("calltime");
    String provinceName = webAction.getParameterString("province");
    
    
    StringBuilder getChannelIdSql = new StringBuilder("select cpid from adminspcp where spcode = '");
    getChannelIdSql.append(callno);
    getChannelIdSql.append("'");
    
    int channelId = SqlUtil.getIntResult(getChannelIdSql.toString(),5);
    int provinceId = BillingUtil.getProvinceId(mobile);
    int ischeck = BillingUtil.getIvrCheckCall(channelId);
    
    StringBuilder conditionSql = new StringBuilder();
    conditionSql.append("'");
	conditionSql.append(mobile);
    conditionSql.append("','");
    conditionSql.append(channelId);
    conditionSql.append("','");
    conditionSql.append(callno);
    conditionSql.append("','");
    conditionSql.append(calltime);
    conditionSql.append("',");
    conditionSql.append(provinceId);
    conditionSql.append(",");
    conditionSql.append(ischeck);
    conditionSql.append(",getDate()");
    
    
    SqlUtil.executeUpdate("insert into  call(mobile,channel,callno,calltime,province,ischeck,createdtime) values("+conditionSql.toString()+")",DbOperation.DB_STAT);
	
    
    /*
    String userPhone = webAction.getParameterString("userNumber");
    String spNo = webAction.getParameterString("spNumber");
    String linkId = webAction.getParameterString("linkId");
    String fee = webAction.getParameterString("fee");
    String content = webAction.getParameterString("msg");
    String date = webAction.getParameterString("getDate");
    
    String province = webAction.getParameterString("province");
    String innerid = webAction.getParameterString("innerid");
    String provincename = webAction.getParameterString("provincename");
    String channel = webAction.getParameterString("channel");
    
    String gatewayId = webAction.getParameterString("gatewayId");
   
    
    
    String mo = webAction.getParameterString("mo");
    
    String srvCode = webAction.getParameterString("srvCode");
    String feeType = webAction.getParameterString("feeType");
    
    //获取用户渠道号
    if(mo==null) {
    	mo = content;
    }
    int channelId = BillingUtil.getUserChannel(spNo,mo);
	//获取是否要扣量
	int ischeck = BillingUtil.getCheckRecv(channelId);
    
    
    System.out.println("*********");
    int provinceId = BillingUtil.getProvinceId(userPhone);
    System.out.println(provinceId);
    StringBuilder sb = new StringBuilder();
    sb.append("'");
    sb.append(provinceId);
    
    sb.append("',");
    sb.append("'");
    sb.append(userPhone);
    sb.append("',");
    sb.append("'");
    sb.append(spNo);
    sb.append("',");
    sb.append("");
    sb.append("getDate()");
    sb.append(",");
    sb.append("'");
    sb.append("msgid");
    sb.append("',");
    sb.append("'");
    sb.append("mid");
    sb.append("',");
    sb.append("'");
    sb.append("1");//cardtype
    sb.append("',");
    sb.append("'");
    sb.append(channelId);//channel
    sb.append("',");
    sb.append("'");
    sb.append("101");//prdid
    sb.append("',");
    sb.append("'");
    sb.append("010");//telid
    sb.append("',");
    sb.append("'");
    sb.append(linkId);//linkid
    sb.append("',");
    sb.append("'");
    sb.append(content);//上行内容
    sb.append("'");
    sb.append(",");
    sb.append(provinceId);
    sb.append(",");
    sb.append(ischeck);
    
    SqlUtil.executeUpdate("insert into "+BillingUtil.getRecvDay()+"(areaid,org,dest,tm,msgid,mid,cardtype,channel,prdid,teleid,linkid,body,province,ischeck) values("+sb.toString()+")",DbOperation.DB_STAT);
	
    response.getWriter().write("OK");
    //String msg = StringUtil.decodeStringByUTF8(webAction.getParameterString("msg"));
	
	//System.out.println("msg:"+msg);
	//合作方url
	String url="";
	if(ischeck==0&&mo.substring(0,5).equals("8DUU1")&&spNo.equals("10663355")){		
		url="http://60.191.223.25:8690/891/mo.aspx";
		System.out.println("空中-迈缘网络-上行同步");
		//url="http://jk.dsmnb.com:8690/891/mo.aspx";
		url=url+"?userPhone="+userPhone+"&spNo="+spNo+"&linkId="+linkId+"&mo="+content+"&date="+date+"";
		System.out.println(url);
		HttpUtil.getHtmlSource(url,"UTF-8");
		//BillingUtil.sendUrl(url);
	}
	else if(ischeck==0&&mo.substring(0,6).equals("8DYU20")&&(spNo.equals("10663355")||spNo.equals("10661660"))){
		url="";
		System.out.println("空中-哗宇通-上行同步");
		//url="http://jk.dsmnb.com:8690/891/mo.aspx";
		url=url+"?userPhone="+userPhone+"&spNo="+spNo+"&linkId="+linkId+"&mo="+content+"&date="+date+"";
		System.out.println(url);
		HttpUtil.getHtmlSource(url,"UTF-8");
	}
	else if(ischeck==0&&mo.substring(0,6).equals("8DYU21")&&(spNo.equals("10663355")||spNo.equals("10661660"))){
		url="http://121.14.118.209:9527/sms/kongjian/kongjianMo.jsp";
		System.out.println("空中-五洲无线-上行同步");
		//url="http://jk.dsmnb.com:8690/891/mo.aspx";
		url=url+"?userPhone="+userPhone+"&spNo="+spNo+"&linkId="+linkId+"&mo="+content+"&date="+date+"";
		System.out.println(url);
		HttpUtil.getHtmlSource(url,"UTF-8");
	}*/
%>
